#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 55;
int a[N];
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		memset(a, 0, sizeof(a));
		for (int i = 1; i <= n; i++)cin >> a[i];
		sort(a + 1, a + n + 1);
		int ma = 0, mi = 0;
		for (int i = 1; i <= n; i++) {
			if (i <= n / 2) mi += a[i];
			else ma += a[i];
		}
		if (n & 1) 	cout << ma - mi - a[n / 2 + 1] << endl;
		else cout << ma - mi << endl;
	}
	return 0;
}